﻿using System.Linq;

namespace Sidvall.IdentityManager.UI.Entities
{
	public sealed partial class ServerItemCollection
	{
		#region Public Members

		#region ClearCustomFields

		public void ClearCustomFields()
		{
			foreach (var serverItem in this)
				serverItem.ClearCustomFields();
		}

		#endregion
		#region ImportCustomFields

		public void ImportCustomFields(ServerItemCollection items)
		{
			if (items == null)
				return;
			foreach (var serverItem in this)
			{
				if (serverItem.ServerItemId == null)
					continue;
				var item = (from o in items
							where o.ServerItemId == serverItem.ServerItemId
							select o).FirstOrDefault();
				serverItem.ImportCustomFields(item);
			}
		}

		#endregion

		#endregion
	}
}